import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_2b_client/apis/MobileAppVersionApi.dart';
import 'package:url_launcher/url_launcher.dart';

showUpdateNotesDialog(BuildContext context, VersionResponse value) {
  showDialog(
    context: context,
    builder: (context) {
      return AlertDialog(
        title: Text("发现新版本（${value.version}）"),
        content: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: value.updateNotes.map((e) => Text(e)).toList(),
        ),
        actions: [
          TextButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            child: const Text("稍后再提醒我"),
          ),
          ElevatedButton(
            onPressed: () {
              launchUrl(Uri.parse("https://www.pgyer.com/nYNxDN"),mode: LaunchMode.externalApplication);
              Navigator.of(context).pop();
            },
            child: const Text("去下载"),
          ),
        ],
      );
    },
  );
}
